<!-- eslint-disable vue/no-unused-vars -->
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
<template>
  <div class="list-model">
    <div class="table-box">
      <el-table
        :data="list"
        size="mini"
        height="calc(100vh - 440px)"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          width="60"
        ></el-table-column>
        <el-table-column
          type="index"
          :label="$t('#')"
          width="90"
        ></el-table-column>
        <el-table-column
          prop="roleName"
          label='用户名称'
          min-width="100"
        ></el-table-column>
        <el-table-column
          prop="tenantCode"
          label='用户组'
          min-width="100"
        >

          <template slot-scope="scope">
            <span>{{scope.row.tenantCode || 'defalut'}}</span>
          </template>
        </el-table-column>
        <el-table-column
          label='邮件'
          prop="roleComment"
          min-width="100"
        >
        </el-table-column>
        <el-table-column
          label='手机'
          prop="roleComment"
          min-width="100"
        >
        </el-table-column>
        <el-table-column
          :label="$t('State')"
          width="60"
        >
          <template slot-scope="scope">
            <span :class="scope.row.state?'act':'dop'">{{scope.row.state === 1 ? `${$t('Enable')}` : `${$t('Disable')}`}}</span>
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('Operation')"
          width="80"
        >
          <template slot-scope="scope">
            <el-tooltip
              content='更换角色'
              placement="top"
            >
              <span @click="changeRole(scope.row)">
                <icon-svg
                  icon-class="icon-qiehuan"
                  style="font-size: 28px;vertical-align: -0.35em;"
                >
                </icon-svg>
              </span>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'permission-list',
    data () {
      return {
        list: [],
        roleDialog: false,
        delDialog: false,
        limited: false,
        roleID: 0,
        item: {},
        selectList: []
      }
    },
    props: {
      roleList: Array,
      pageNo: Number,
      pageSize: Number
    },
    methods: {
      handleSelectionChange (rows) {
        this.selectList = rows
      },
      changeRole (row) {
        this.$emit('changeRoleById', row)
      }
    },
    watch: {
      roleList (a) {
        this.list = []
        setTimeout(() => {
          this.list = a
        })
      }
    },
    created () {
      this.list = this.roleList
    }
  }
</script>
<style lang="scss" scoped>
.act {
  color: #5ab92f;
}
.dop {
  color: #f56c6c;
}
</style>
